import http from "@/config/config";


const taocanApi = {

  //获取套餐
  getTaoCans:(page: Number,size: Number)=>{
    return http.post(`/taocan/page/${page}/${size}`,{}).then(res=>{
        return res.data;
    })
  },
  //根据套餐名称获取套餐
  pageSearchWrapper:(page: Number,size: Number,map:any)=>{
    return http.post(`/taocan/page/${page}/${size}`,{
      "name":map.name,
      "category":map.category,
      "status":map.status
    }).then(res=>{
      return res.data;
   })
  },
  //添加套餐
  insertTaocan:(taocanVo:any)=>{
   return http.post('/taocan/add',{
      "name":taocanVo.name,
      "category":taocanVo.category,
      "price":taocanVo.totalPirce,
      "img":taocanVo.img,
      "status":taocanVo.status,
      "description":taocanVo.description,
      "dishList":taocanVo.dishes
   }).then(res=>{
        return res.data;
    })
  },
  //根据套餐id获取套餐的基本信息
  getTaoCanById:(id:Number)=>{
    return http.get(`/taocan/${id}`).then(res=>{
      return res.data;
    })
  },
  //修改套餐
  updateTaocan:(taocanVo:any)=>{
    return http.put('/taocan/update',{
      "id":taocanVo.id,
      "name":taocanVo.name,
      "category":taocanVo.category,
      "price":taocanVo.totalPirce,
      "img":taocanVo.img,
      "status":taocanVo.status,
      "description":taocanVo.description,
      "dishList":taocanVo.dishes
   }).then(res=>{
        return res.data;
    })
  },

    //修改套餐售卖状态
    changeStatus:(id:Number,status:Number)=>{
      return http.get(`/taocan/status/${id}/${status}`).then(res=>{
        return res.data;
      })
   },

   //批量删除套餐
   deleteTaocans:(ids:any)=>{
    return http.post('/taocan/delete',{
      "ids":ids
    }).then(res=>{
      return res.data
    })
   }

}

export default taocanApi;